<html>
<head><meta charset="utf-8"><title>Getting substitution from impl to trait · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20substitution.20from.20impl.20to.20trait.html">Getting substitution from impl to trait</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="238447960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Getting%20substitution%20from%20impl%20to%20trait/near/238447960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20substitution.20from.20impl.20to.20trait.html#238447960">(May 12 2021 at 09:48)</a>:</h4>
<p>Is there anyway to get the substitution for the generic parameters of an impl to those of the trait it's implementing?</p>
<p>I mean given:</p>
<div class="codehilite"><pre><span></span><code>trait T { fn x(self); }

impl T for (T1, T2) { .. }
</code></pre></div>
<p>I'd like a substution with the content <code>Self -&gt; (T1, T2)</code></p>



<a name="238448210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Getting%20substitution%20from%20impl%20to%20trait/near/238448210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20substitution.20from.20impl.20to.20trait.html#238448210">(May 12 2021 at 09:51)</a>:</h4>
<p>I'm doing this after type checking so this substitution must have been calculated during trait resolution, is there anyway to recover that information?</p>



<a name="238448957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Getting%20substitution%20from%20impl%20to%20trait/near/238448957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20substitution.20from.20impl.20to.20trait.html#238448957">(May 12 2021 at 09:59)</a>:</h4>
<p>Hmm, I may have answered my own question: I believe that <code>impl_trait_ref</code> does exactly what I want</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>